﻿#region

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using Pob.GameObjects.PowerUps.General;

#endregion

namespace Pob
{
    public enum Side
    {
        Left, 

        Right
    }

    public class Player : GameComponent
    {
        #region Constructors and Destructors

        public Player(Game game, string name, Keys up, Keys down, Keys powerUp, Side side)
            : base(game)
        {
            Name = name;

            Score = 0;

            KeyUp = up;

            KeyDown = down;

            StoredPowerUp = null;

            Side = side;

            KeyPowerUp = powerUp;
        }

        #endregion

        #region Public Properties

        public Keys KeyDown { get; set; }

        public Keys KeyPowerUp { get; set; }

        public Keys KeyUp { get; set; }

        public string Name { get; set; }

        public int Score { get; private set; }

        public Side Side { get; private set; }

        public PowerUp StoredPowerUp { get; set; }

        #endregion

        #region Public Methods and Operators

        public void ActivatePowerUp(GameTime gameTime)
        {
            StoredPowerUp.ActivateEffect(this, gameTime);

            StoredPowerUp = null;
        }

        public bool IncreaseScore()
        {
            Score++;

            return Score >= 9;
        }

        public bool StorePowerUp(PowerUp powerUp)
        {
            if (StoredPowerUp == null)
            {
                StoredPowerUp = powerUp;
                return true;
            }

            return false;
        }

        #endregion
    }
}